<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="STYLESHEET" href="print_static.css" type="text/css" />
<style type="text/css">
body{
	padding: 0.3in 0.5in 0.5in 0.5in;
}
table { width: 100%; }
td {text-align: center; }
h1 {font-size:160%; text-align:center;}

.logo { float:left; font-size:7; font-weight:bold; text-align:center}
.logo table {width: 25%;}
.logo td {border: 0; }

.tabla td {height: 70px; text-align: justify;}
.tabla td .rol { text-align:right; width:25%}
.materia {}
.foot { width: 100%;}
.espacio {height:50px;}
div.salto{
	height:1px; width:100%;
	page-break-after: always
}
h3{
	text-aling:justify;
}
#data{ margin-left:180px;text-align:justify;}
</style>

</head>

<body>

<script type="text/php">
$header=$pdf->open_object();
$font = Font_Metrics::get_font("Sans-serif", "normal");
$texto = "www.termaule.cl";
$hpagina = $pdf->get_height();
$wpagina = $pdf->get_width();
$wtexto = Font_Metrics::get_text_width($texto, $font, 12);
$pdf->page_text($wpagina/2 - $wtexto/2, $hpagina-100, $texto,
$font, 14, array(0,0,0));
$pdf->close_object();
$pdf->add_object($header, "all");
</script>

<?php

$cantidad = $results -> num_rows;
if($cantidad <= 5)
	$iter = 1;
if($cantidad > 5 AND $cantidad <= 10)
	$iter = 2;
if($cantidad > 10 AND $cantidad <= 20)
	$iter = 3;
$j = 0;
for ($i = 1 ; $i <= $iter ; $i++):
?>
<div id="titulo">
<table>
		<tr>
			<td><h1>TRIBUNAL ELECTORAL REGIONAL DEL MAULE<br />TALCA</h1></td>
		</tr>
</table>
<div id="data">
	<?php
		echo $this->my_library->dayMonthYear($fecha_ejecucion)."<br />";
		echo 'Audiencia: '.$hora."<br />";
		echo 'Relator: '.$relator;
	?>
</div>
</div>
<br />
<h3>Tabla en conformidad  articulo 21 de la ley n° 18.593, de los Tribunales Electorales <br/>Regionales.</h3>
<br />
<div class="tabla">
<table cellspacing="2">
	<?php
	$search = array("<br />","\n");
	while ($j < $cantidad)
	{
		
		$row = $results ->row($j);
		$materia = str_replace ($search  ,'', $row->materia );	
		echo "<tr><td width='75%' style='text-transform:uppercase'>".($j+1).".-&nbsp;&nbsp;&nbsp;".wordwrap($materia, 47, "<br />\n")."</td>";
		echo "<td class='rol'>&nbsp;&nbsp;&nbsp;Rol nº ".$row->rol_causa.".-</td>";
		if(($j+1) == 5 || ($j+1) == 10 || ($j+1) == 20)
		{ 
			break;
		}
		$j=$j+1;
	}
	$j=$j+1;
	?>
</table>
<?php 
	echo "<br /><br /><br /><br />Talca, ".$this->my_library->dayMonthYear($fecha_creacion)."<br />";	
?>
</div>
<div class="espacio"></div>

<div class="foot">
	<table>
		<tr>
			<td><?php echo $relator;?><br />______________________________<br />SECRETARIO RELATOR</td>
			<td><?php echo $presidente;?><br />______________________________<br />PRESIDENTE</td>
		</tr>
		
	</table>
</div>
<div class="salto"></div>
<?php endfor;?>
</body>
</html>